﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Tomahawk.Resources.Physics
{
    class CollisionReader : ContentTypeReader<PhysicsActorDesc>
    {
        #region Properties
        public delegate bool InitCollisionDelegate(PhysicsActorDesc descriptor);
        public static event InitCollisionDelegate OnInitCollision;
        #endregion

        protected override PhysicsActorDesc Read(ContentReader input, PhysicsActorDesc existingInstance)
        {
            XmlSerializer x = new XmlSerializer(typeof(PhysicsActorDesc));
            PhysicsActorDesc output = (PhysicsActorDesc)x.Deserialize(input.BaseStream);

            if (OnInitCollision != null)
            {
                OnInitCollision(output);
            }

            return output;
        }
    }
}
